package com.example.player.dao;

import android.content.Context;

import androidx.annotation.NonNull;
import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;

import com.example.player.domain.entity.PlayList;
import com.example.player.domain.entity.Song;
import com.example.player.domain.entity.SongListRela;
/**
 * 数据库
 * @author 朱文权
 * */
@Database(entities = {Song.class, SongListRela.class, PlayList.class},version = 1)
public abstract class AppDatabase extends RoomDatabase {
    public abstract SongDao songDao();
    public abstract SongListRelaDao songListRelaDao();
    public abstract PlayListDao playListDao();
    private static volatile AppDatabase INSTANCE;
    public static AppDatabase getInstance(final Context context) {
        if (INSTANCE == null) {
            synchronized (AppDatabase.class) {
                if (INSTANCE == null) {
                    INSTANCE = Room.databaseBuilder(
                            context.getApplicationContext(),
                            AppDatabase.class,
                            "my_database"
                    ).build();
                }
            }
        }
        return INSTANCE;
    }

}
